import requests
#添加员工
url="http://ihrm-test.itheima.net/api/sys/user"
header={"Content-Type":"application/json","Authorization":"9e40b5a4-553e-4062-94f2-307b90b20084"}
body={"username":"张三","mobile":"15727394587","workNumber":"002"}
session=requests.Session()
res=session.post(url=url,headers=header,json=body)
print("添加员工:",res.json())
#查询员工
url_query="http://ihrm-test.itheima.net/api/sys/user/1505197733198290944"
header_query={"Content-Type":"application/json","Authorization":"9e40b5a4-553e-4062-94f2-307b90b20084"}
session_query=requests.Session()
res_query=session_query.get(url=url_query,headers=header)
print("查询员工:",res_query.json())
#修改员工
url_modify="http://ihrm-test.itheima.net/api/sys/user/1505197733198290944"
header_modify={"Content-Type":"application/json","Authorization":"9e40b5a4-553e-4062-94f2-307b90b20084"}
data_modify={"username":"美女"}
session_modify=requests.Session()
res_modify=session_modify.put(url=url_query,headers=header,json=data_modify)
print("修改员工:",res_modify.json())
#删除员工
url_del="http://ihrm-test.itheima.net/api/sys/user/1505197733198290944"
header_del={"Content-Type":"application/json","Authorization":"9e40b5a4-553e-4062-94f2-307b90b20084"}
session_del=requests.Session()
res_del=session_del.delete(url=url_query,headers=header)
print("删除员工:",res_del.json())